/*
 * Copyright (c) 2018-2999 广州市蓝海创新科技有限公司 All rights reserved.
 *
 * https://www.mall4j.com/
 *
 * 未经允许，不可做商业用途！
 *
 * 版权所有，侵权必究！
 */
package com.yami.shop.distribution.api.controller;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.yami.shop.common.response.ServerResponseEntity;
import com.yami.shop.common.util.PageParam;
import com.yami.shop.distribution.common.dto.DistributionMsgDto;
import com.yami.shop.distribution.common.model.DistributionMsg;
import com.yami.shop.distribution.common.service.DistributionMsgService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author yami
 */
@RestController
@RequestMapping("/p/distribution/msg")
@Api(tags = "分销公告接口")
public class DistributionMsgController {

    @Autowired
    private DistributionMsgService distributionMsgService;

    @GetMapping("/info")
    @ApiOperation(value = "获取公告详情", notes = "根据公告id获取")
    @ApiImplicitParam(name = "msgId", value = "公告id", required = true, dataType = "Long")
    public ServerResponseEntity<DistributionMsgDto> info(Long msgId){
        return ServerResponseEntity.success(distributionMsgService.getDistributionMsgDtoByMsgId(msgId));
    }

    @GetMapping("/page")
    @ApiOperation(value = "公告列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "isTop", value = "是否置顶", dataType = "Integer")
    })
    public ServerResponseEntity<IPage<DistributionMsgDto>> page(PageParam<DistributionMsg> page,
                                                          @RequestParam(value = "isTop", required = false) Integer isTop) {
        return ServerResponseEntity.success(distributionMsgService.getDistributionMsgDtoShopId(page,isTop));
    }
}
